package day18.afternoon;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;

public class DouDiZhuGame {
    /**
     * 将54张扑克牌初始化并放在对应的集合里面
     */
    ArrayList PuKe = new ArrayList();
    public void init(){
      for (int i = 3;i < 11;i++){
          PuKe.add(new PuKe(i + "","红桃"));
          PuKe.add(new PuKe(i + "","黑桃"));
          PuKe.add(new PuKe(i + "","梅花"));
          PuKe.add(new PuKe(i + "","方块"));
      }
        PuKe.add(new PuKe("J","红桃"));
        PuKe.add(new PuKe("J","黑桃"));
        PuKe.add(new PuKe("J","梅花"));
        PuKe.add(new PuKe("J","方块"));

        PuKe.add(new PuKe("Q","红桃"));
        PuKe.add(new PuKe("Q","黑桃"));
        PuKe.add(new PuKe("Q","梅花"));
        PuKe.add(new PuKe("Q","方块"));

        PuKe.add(new PuKe("K","红桃"));
        PuKe.add(new PuKe("K","黑桃"));
        PuKe.add(new PuKe("K","梅花"));
        PuKe.add(new PuKe("K","方块"));

        PuKe.add(new PuKe("A","红桃"));
        PuKe.add(new PuKe("A","黑桃"));
        PuKe.add(new PuKe("A","梅花"));
        PuKe.add(new PuKe("A","方块"));

        PuKe.add(new PuKe("大王",null));
        PuKe.add(new PuKe("小王",null));
    }

    /**
     * 洗牌
     */
    public void xipai(){
        Collections.shuffle(PuKe);
        for (Object obj:PuKe){
            PuKe p = (day18.afternoon.PuKe) obj;
            System.out.println(p.getPoint() + p.getType());
        }
    }

    /**
     * 发牌
     */
    public void send(){
        ArrayList<String> arrayList= new ArrayList(PuKe.subList(0,17));
        System.out.println("第一家" + arrayList);
        ArrayList<String> arrayList1 = new ArrayList(PuKe.subList(17,34));
        System.out.println("第二家" + arrayList1);
        ArrayList<String> arrayList2 = new ArrayList(PuKe.subList(34,51));
        System.out.println("第三家" + arrayList2);
        ArrayList<String> arrayList3 = new ArrayList(PuKe.subList(51,53));
        System.out.println("地主牌" + arrayList3);

    }

    public static void main(String[] args) {

//        PuKe puke = new PuKe("2","黑桃");
//        System.out.println(puke);
        DouDiZhuGame d = new DouDiZhuGame();
        d.init();
        d.xipai();
        d.send();

    }
}